package com.wondertek.poms.core.service.impl;

import com.wondertek.poms.common.service.impl.ServiceImpl;
import com.wondertek.poms.core.service.IPomsExportLogService;
import com.wondertek.poms.dao.po.PomsExportLog;
import com.wondertek.poms.dao.repo.IPomsExportLogDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author evan0213
 * @description
 */
@Slf4j
@Service
public class PomsExportLogServiceImpl extends ServiceImpl<PomsExportLog, Long> implements IPomsExportLogService {
	@Autowired
	private IPomsExportLogDao pomsExportLogDao;

	@Override
	public PomsExportLog deleteLogic(Long id) {
		return null;
	}

	@Override
	public PomsExportLog merge(PomsExportLog model) {
		return null;
	}

	/**
	 * @param type        输出类型：1，节目；2，产品包；3，热点主题；4，位置
	 * @param pomsId      type=1，节目ID；type=2，产品包ID；type=3，热点主题ID；type=4，位置ID
	 * @param status      POMS内容状态：1，上线；0，下线
	 * @param publishTime 更新时间
	 */
	@Override
	public void updateLog(String type, Long pomsId, String status, Date publishTime) {
		PomsExportLog pomsExportLog = pomsExportLogDao.findByPomsIdAndType(pomsId, type);
		if (pomsExportLog != null) {
			pomsExportLog.setPublishTime(publishTime);
			pomsExportLog.setStatus(status);
		} else {
			pomsExportLog = new PomsExportLog();
			pomsExportLog.setPomsId(pomsId);
			pomsExportLog.setType(type);
			pomsExportLog.setStatus(status);
			pomsExportLog.setPublishTime(publishTime);
		}
		pomsExportLogDao.save(pomsExportLog);
		log.info("==修改portal数据 type[" + type + "] pomsId[" + pomsId + "] status[" + status + "] 成功==");
	}
}
